﻿Public Class player
    Dim xTemp As String
    Dim xFile As String
    Dim xNilai As Integer = 0
    Dim xNilaiPuzzle As Integer = 0
    Dim xNama As String
    Dim xUrutan As Integer = 0
    Dim xNamaTxt As String
    Dim xSkorPuzzleTxt As String
    Dim xSkorTxt As String
    Dim xCurrent As String = System.IO.File.ReadAllText("CurrentPlayer.txt")
    Public Property Temp As String
        Get
            Return xTemp
        End Get
        Set(ByVal value As String)
            xTemp = value
        End Set
    End Property
    Public Property File As String
        Get
            Return xFile
        End Get
        Set(ByVal value As String)
            xFile = value
        End Set
    End Property

    Public Property Nilai As Integer
        Get
            Return xNilai
        End Get
        Set(ByVal value As Integer)
            xNilai = value
        End Set
    End Property
    Public Property urutan As Integer
        Get
            Return xUrutan
        End Get
        Set(ByVal value As Integer)
            xUrutan = value
        End Set
    End Property

    Public Property NilaiPuzzle As Integer
        Get
            Return xNilaiPuzzle
        End Get
        Set(ByVal value As Integer)
            xNilaiPuzzle = value
        End Set
    End Property
    Public Property Player As String
        Get
            Return xNama
        End Get
        Set(ByVal value As String)
            xNama = value
        End Set
    End Property
    Public Sub Tambah()
       
        Dim xNamaPlayer() As String = Split(System.IO.File.ReadAllText("jumlahplayer.txt"), vbCrLf)
        If xNamaPlayer.Count = 1 Then
            System.IO.File.AppendAllText("jumlahplayer.txt", Player)
        Else
            System.IO.File.AppendAllText("jumlahplayer.txt", vbCrLf & Player)
        End If

        xNamaTxt = xNama & ".txt"
        Dim xWriter As New System.IO.StreamWriter(xNamaTxt)
        xSkorTxt = xNama & "skor.txt"
        Dim xSkorWriter As New System.IO.StreamWriter(xSkorTxt)
        xSkorPuzzleTxt = xNama & "puzzleskor.txt"
        Dim xSkorPuzzleWriter As New System.IO.StreamWriter(xSkorPuzzleTxt)

    End Sub
    Public Sub nama()
        System.IO.File.WriteAllText("CurrentPlayer.txt", xTemp)
    End Sub
    Public Sub belajar()

        Dim xFormBelajar As String
        xFormBelajar = Form.ActiveForm.Text
        System.IO.File.AppendAllText(xCurrent & ".txt", xFormBelajar & vbCrLf)
    End Sub
    Public Sub skor(ByVal i As Integer)
        System.IO.File.WriteAllText(xCurrent & "skor.txt", i & vbCrLf)
    End Sub
    Public Sub skorpuzzle()

        System.IO.File.WriteAllText(xCurrent & "puzzleskor.txt", xNilaiPuzzle & vbCrLf)
    End Sub

    Public Sub hapus()
        Dim xNamaPlayer() As String = Split(System.IO.File.ReadAllText("jumlahplayer.txt"), vbCrLf)

        System.IO.File.Delete("jumlahplayer.txt")
        System.IO.File.Delete(xNamaPlayer(xUrutan) & ".txt")
        System.IO.File.Delete(xNamaPlayer(xUrutan) & "skor.txt")
        System.IO.File.Delete(xNamaPlayer(xUrutan) & "puzzleskor.txt")
        Dim xPointer As Integer = 1
        For i As Integer = 0 To UBound(xNamaPlayer)
            If xNamaPlayer.Count = 1 Then
                System.IO.File.AppendAllText("jumlahplayer.txt", "")

            End If
            MsgBox(xPointer)
            If i <> xUrutan Then
                If xPointer = 1 Then
                    System.IO.File.AppendAllText("jumlahplayer.txt", xNamaPlayer(i))
                    xPointer = 2
                Else
                    System.IO.File.AppendAllText("jumlahplayer.txt", vbCrLf & xNamaPlayer(i))
                End If
            End If
        Next
       

    End Sub
    Public Sub tulisulang()
       
    End Sub
End Class
